<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
class editor extends CWidget{
    public $config=array();
    public $width='600px';
    public $height='500px';
    public $name='';
    public $content='';
    public function run(){
        $assets = dirname(__FILE__).'/assets';
        $baseUrl = Yii::app()->assetManager->publish($assets);
        Yii::app()->clientScript->registerScriptFile($baseUrl . '/ueditor.config.js', CClientScript::POS_HEAD);
        Yii::app()->clientScript->registerScriptFile($baseUrl . '/ueditor.all.js', CClientScript::POS_HEAD);
        $config=",".CJavaScript::encode($this->config);
        echo '<script id="container" name="'.$this->name.'" style="width:'.$this->width.';height:'.$this->height.'" type="text/plain">'.$this->content.'</script>';
        Yii::app()->getClientScript()->registerScript("ueditor_".$this->id, "var ue = UE.getEditor('container'$config); ",CClientScript::POS_LOAD);
    }
}
